package com.chuangjiangx.member.stored.ddd.domain.event;

import com.chuangjiangx.domain.shared.model.PayEntry;
import com.chuangjiangx.domain.shared.model.PayTerminal;
import com.chuangjiangx.domain.shared.model.PayType;
import com.chuangjiangx.member.basic.ddd.domain.model.OperatorInfo;
import lombok.Getter;

import java.math.BigDecimal;

/**
 * @author cj-ch
 * @date 2018/5/22 下午3:50
 */
@Getter
public class MbrRefundSuccessEvent {
    /** *****会员信息***** */
    private Long memberId;
    private Long merchantId;
    /**
     * 客户相对与服务商的openid
     */
    private String openId;

    /** *****支付信息***** */
    /**
     * order_pay表的订单编号
     */
    private String orderPayNumber;
    /**
     * 会员订单Id
     */
    private Long mbrOrderId;
    private BigDecimal amount;
    private BigDecimal realPayAmount;
    private PayEntry payEntry;
    private PayType payType;
    private Integer payChannelId;
    private PayTerminal payTerminal;

    /** *****退款信息***** */
    /**
     * order_refund表退款单号
     */
    private String orderRefundNumber;
    /**
     * 会员退款Id
     */
    private Long mbrOrderRefundId;
    /**
     * 退款总金额
     */
    private BigDecimal totalRefundAmout;
    /**
     * 本次退款金额
     */
    private BigDecimal currentRefundAmout;

    /** *****操作人信息***** */
    private Long merchantUserId;
    private Long storeId;
    private Long storeUserId;
    private String storeAddress;
    private String merchantAddress;

    private MbrRefundSuccessEvent(){}

    public OperatorInfo getOperatorInfo(){
        return new OperatorInfo(
                this.merchantId,
                this.merchantUserId,
                this.storeUserId,
                this.storeId,
                this.storeAddress,
                this.merchantAddress
        );
    }


    @Override
    public String toString() {
        return "MbrRefundSuccessEvent{" +
                "memberId=" + memberId +
                ", merchantId=" + merchantId +
                ", openId='" + openId + '\'' +
                ", orderPayNumber='" + orderPayNumber + '\'' +
                ", mbrOrderId=" + mbrOrderId +
                ", amount=" + amount +
                ", realPayAmount=" + realPayAmount +
                ", payEntry=" + payEntry +
                ", payType=" + payType +
                ", payChannelId=" + payChannelId +
                ", payTerminal=" + payTerminal +
                ", orderRefundNumber='" + orderRefundNumber + '\'' +
                ", mbrOrderRefundId=" + mbrOrderRefundId +
                ", totalRefundAmout=" + totalRefundAmout +
                ", currentRefundAmout=" + currentRefundAmout +
                ", merchantUserId=" + merchantUserId +
                ", storeId=" + storeId +
                ", storeUserId=" + storeUserId +
                ", storeAddress='" + storeAddress + '\'' +
                ", merchantAddress='" + merchantAddress + '\'' +
                '}';
    }

    public static class MbrRefundSuccessEventBuild{

        private Long memberId;
        private Long merchantId;
        private String openId;


        private String orderPayNumber;
        private Long mbrOrderId;
        private BigDecimal amount;
        private BigDecimal realPayAmount;
        private PayEntry payEntry;
        private PayType payType;
        private Integer payChannelId;
        private PayTerminal payTerminal;


        private String orderRefundNumber;
        private Long mbrOrderRefundId;
        private BigDecimal totalRefundAmout;
        private BigDecimal currentRefundAmout;


        private Long merchantUserId;
        private Long storeId;
        private Long storeUserId;
        private String storeAddress;
        private String merchantAddress;

        public MbrRefundSuccessEventBuild(){}

        public MbrRefundSuccessEvent build(){
            MbrRefundSuccessEvent e = new MbrRefundSuccessEvent();
            e.memberId=this.memberId;
            e.merchantId=this.merchantId;
            e.openId=this.openId;

            e.orderPayNumber=this.orderPayNumber;
            e.mbrOrderId=this.mbrOrderId;
            e.amount=this.amount;
            e.realPayAmount=this.realPayAmount;
            e.payEntry=this.payEntry;
            e.payType=this.payType;
            e.payChannelId=this.payChannelId;
            e.payTerminal=this.payTerminal;

            e.orderRefundNumber=this.orderRefundNumber;
            e.mbrOrderRefundId=this.mbrOrderRefundId;
            e.totalRefundAmout=this.totalRefundAmout;
            e.currentRefundAmout=this.currentRefundAmout;

            e.merchantUserId=this.merchantUserId;
            e.storeId=this.storeId;
            e.storeUserId=this.storeUserId;
            e.storeAddress=this.storeAddress;
            e.merchantAddress=this.merchantAddress;
            return e;
        }

        public MbrRefundSuccessEventBuild setMemberId(Long memberId) {
            this.memberId = memberId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setMerchantId(Long merchantId) {
            this.merchantId = merchantId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setOpenId(String openId) {
            this.openId = openId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setOrderPayNumber(String orderPayNumber) {
            this.orderPayNumber = orderPayNumber;
        	return this;
		}

        public MbrRefundSuccessEventBuild setMbrOrderId(Long mbrOrderId) {
            this.mbrOrderId = mbrOrderId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setAmount(BigDecimal amount) {
            this.amount = amount;
        	return this;
		}

        public MbrRefundSuccessEventBuild setRealPayAmount(BigDecimal realPayAmount) {
            this.realPayAmount = realPayAmount;
        	return this;
		}

        public MbrRefundSuccessEventBuild setPayEntry(PayEntry payEntry) {
            this.payEntry = payEntry;
        	return this;
		}

        public MbrRefundSuccessEventBuild setPayType(PayType payType) {
            this.payType = payType;
        	return this;
		}

        public MbrRefundSuccessEventBuild setPayChannelId(Integer payChannelId) {
            this.payChannelId = payChannelId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setPayTerminal(PayTerminal payTerminal) {
            this.payTerminal = payTerminal;
        	return this;
		}

        public MbrRefundSuccessEventBuild setOrderRefundNumber(String orderRefundNumber) {
            this.orderRefundNumber = orderRefundNumber;
        	return this;
		}

        public MbrRefundSuccessEventBuild setMbrOrderRefundId(Long mbrOrderRefundId) {
            this.mbrOrderRefundId = mbrOrderRefundId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setTotalRefundAmout(BigDecimal totalRefundAmout) {
            this.totalRefundAmout = totalRefundAmout;
        	return this;
		}

        public MbrRefundSuccessEventBuild setCurrentRefundAmout(BigDecimal currentRefundAmout) {
            this.currentRefundAmout = currentRefundAmout;
        	return this;
		}

        public MbrRefundSuccessEventBuild setMerchantUserId(Long merchantUserId) {
            this.merchantUserId = merchantUserId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setStoreId(Long storeId) {
            this.storeId = storeId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setStoreUserId(Long storeUserId) {
            this.storeUserId = storeUserId;
        	return this;
		}

        public MbrRefundSuccessEventBuild setStoreAddress(String storeAddress) {
            this.storeAddress = storeAddress;
            return this;
        }

        public MbrRefundSuccessEventBuild setMerchantAddress(String merchantAddress) {
            this.merchantAddress = merchantAddress;
            return this;
        }
    }


}
